<?php

namespace App\Http\Requests\Admin;

use App\Http\Requests\ApiRequest;
use Illuminate\Http\UploadedFile;

/**
 * @property int video_type_id
 * @property string name
 * @property string url
 * @property UploadedFile preview_img
 * @property mixed sort
 * @property mixed english_title
 */

class VideoStoreRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'video_type_id' => 'required|numeric',
            'name'          => 'required|string',
            'url'           => 'required',
            'preview_img'   => 'required|file|max:2048',
            'sort'          => 'sometimes|numeric',
            'english_title' => 'sometimes|string',
        ];
    }

    /**
     * @return array
     */
    public function messages()
    {
        return [
            'video_type_id.*' => ':attribute必须是数值',
            'name.*'          => ':attribute必须是字符串',
            'url.*'           => ':attribute必须是字符串',
            'preview_img.*'   => ':attribute必须是小于2048的上传文件',
            'sort.*'          => ':attribute必须是数值',
            'english_title.*' => ':attribute必须是字符串',
        ];
    }

    /**
     * @return array
     */
    public function attributes()
    {
        return [
            'video_type_id' => '视频类型',
            'name'          => '视频名称',
            'url'           => '视频的路径',
            'preview_img'   => '视频的封面图',
            'sort'          => '视频排序',
            'english_title' => '英文标题',
        ];
    }
}
